package com.base.system.managedBean;

import java.io.Serializable;

import org.operamasks.faces.annotation.Action;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import org.operamasks.faces.user.util.Browser;

import com.base.commons.SpringBeanHolder;
import com.base.organization.service.IOrganizationService;
import com.base.security.interceptor.BPFilterInvocationSecurityMetadataSource;

/**
 * 
 * This managed bean is generated automatically
 */
@ManagedBean(name = "system_refreshPrivilegeBean", scope = ManagedBeanScope.REQUEST)
public class RefreshPrivilegeBean implements Serializable {

	@Action(id = "refreshPrivilege")
	public void refreshPrivilege() {
		// System.out.println("刷新权限执行了。。。");
		BPFilterInvocationSecurityMetadataSource fids = SpringBeanHolder
				.getBean("bpFilterInvocationSecurityMetadataSource");
		// 刷新权限
		fids.reloadConfigAttribute();
		// FilterSecurityInterceptor filter = (FilterSecurityInterceptor)
		// SpringBeanHolder
		// .getBean("resourceSecurityInterceptor");
		// filter.setSecurityMetadataSource(fids);
		Browser.execClientScript("window.alert('已成功刷新授权')");
	}

	@Action(id = "refreshManagementDept")
	public void refreshManagementDept() {
		IOrganizationService orgService = SpringBeanHolder
				.getBean("orgService");
		orgService.initAll();
		Browser.execClientScript("window.alert('已成功刷新人力资源结构')");
	}
}
